package com.heima.common.tess4j;

import lombok.Getter;
import lombok.Setter;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.awt.image.BufferedImage;
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "tess4j")
public class tess4jClient {

    private String DataPath;
    private String Language;

    public String doDCR(BufferedImage image) throws TesseractException {
        Tesseract tesseract = new Tesseract();
        tesseract.setDatapath(DataPath);
        tesseract.setLanguage(Language);
        String doOCR = tesseract.doOCR(image);
        return doOCR.replaceAll("[^\\u4E00-\\u9FA5]+", "-");
    }
}
